package com.it.jdbc.druid;

import com.alibaba.druid.pool.DruidDataSourceFactory;

import javax.sql.DataSource;
import java.io.InputStream;
import java.sql.Connection;
import java.util.Properties;

/**
 * druid连接池的使用
 */
public class DruidDemo01 {
    public static void main(String[] args) throws Exception{
        //1.加载配置文件
        Properties properties = new Properties();
        InputStream is = DruidDemo01.class.getClassLoader().getResourceAsStream("druid.properties");
        properties.load(is);
        //2.创建dataSource
        DataSource dataSource = DruidDataSourceFactory.createDataSource(properties);
        //3.获取dataSource
        Connection connection = dataSource.getConnection();
        System.out.println(connection);
    }
}
